package com.wang.bootbuilder.service;

import com.wang.bootbuilder.entity.pojo.Product;
import com.wang.bootbuilder.mapper.ProductMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;

@Component
public class TestTran {

    @Autowired
    ProductMapper productMapper;

    @Transactional(propagation = Propagation.REQUIRED)
    public void splitTest12() {
        // 添加商品
        Product insertProduct = new Product();
        insertProduct.setCategoryId(123456L);
        insertProduct.setPcategoryId(78945646L);
        insertProduct.setProductName("bbbbbb");
        insertProduct.setProductDesc("bnknm");
        insertProduct.setPrice(new BigDecimal("100"));
        insertProduct.setStatus(0);

        productMapper.insert(insertProduct);
//        try {
//            int i = 1/0;
//        } catch (Exception e) {
//            e.printStackTrace();
//        }

    }

//    @Resource
//    private StudentTestMapper studentTestMapper;
//
//    @Resource
//    private StudentCopyService studentCopyService;
//
//    @Resource
//    private StudentCopyMapper studentCopyMapper;
//
//    @Transactional
//    public void insert1() {
//        StudentTest studentTest = new StudentTest();
//        studentTest.setId(99);
//        studentTest.setName("一定成功都");
//        studentTest.setCourse("试一试");
//        studentTest.setScore("试一试");
//        studentTestMapper.insert(studentTest);
//        try {
//            studentCopyService.insert2();
//        }catch (Exception e){
//            System.out.println("不做处理");
//        }
//    }
//
//
//    public void insert2() {
//        StudentCopy studentCopy = new StudentCopy();
//        studentCopy.setId(99);
//        studentCopy.setName("试一试长度太长啦太长啦太长啦太长啦太长啦");//name得长度 超出了
//        studentCopy.setCourse("试一试");
//        studentCopy.setScore("试一试");
//        studentCopyMapper.insert(studentCopy);
//    }

}
